package com.aote.entity.component;

import org.w3c.dom.Element;

import com.browsesoft.Entity;
import com.browsesoft.htmlcomponent.HTMLBasicComponent;

public class ParentIDTransmitButton extends HTMLBasicComponent {

	public ParentIDTransmitButton(HTMLBasicComponent parent) throws Exception {
		super(parent);
	}

	/**
	 * 
	 */
	protected void updateElement() throws Exception {
		super.updateElement();
		// 得到父组件对应的实体
		Entity entity = (Entity) this.getParent().getModel();
		String id = entity.getID();
		// 得到此按钮的元素，并把onclick属性中的#parentid#给换掉
		Element element = this.getElement();
		String str = element.getAttribute("onclick");
		str = str.replaceAll("#parentid#", id);
		element.setAttribute("onclick", str);
	}

}
